package cj.web.sc.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.sc.domain.SCCart;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCCartDAO{
	
	@SQL("SELECT * FROM SCCart WHERE 1=1 "
	    	    				    		        	+ " AND buyerId=:t.buyerId,"
	        			    		        	+ " AND sellerId=:t.sellerId,"
	        			    		        	+ " AND goodsItemId=:t.goodsItemId,"
	        			    		        	+ " AND count=:t.count,"
	        			    		        	+ " AND status=:t.status,"
	        			    		        	+ " AND deleteFlag=:t.deleteFlag,"
	        			    		        	+ " AND createUser=:t.createUser,"
	        			    		        	+ " AND createAt=:t.createAt,"
	        			    		        	+ " AND updateUser=:t.updateUser,"
	        			    		        	+ " AND updateAt=:t.updateAt,"
	        				+" ORDER BY update_date DESC LIMIT :t.start,:t.end ")
    List<SCCart> query(@SQLParam("t") SCCart sCCart);
    
    @SQL("select * from SCCart where id=:1")
    SCCart queryById(String id);
    
    @SQL("INSERT INTO SCCart ("
    		        		+ "id,"
			        		+ "buyerId,"
			        		+ "sellerId,"
			        		+ "goodsItemId,"
			        		+ "count,"
			        		+ "status,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt,"
			        		+ "updateUser,"
			        		+ "updateAt,"
							+") VALUES ("
							+ ":t.id,"
							+ ":t.buyerId,"
							+ ":t.sellerId,"
							+ ":t.goodsItemId,"
							+ ":t.count,"
							+ ":t.status,"
							+ ":t.deleteFlag,"
							+ ":t.createUser,"
							+ ":t.createAt,"
							+ ":t.updateUser,"
							+ ":t.updateAt,"
					+")")
    void create(@SQLParam("t") SCCart sCCart);
	
	@SQL("UPDATE SCCart SET "
		    		    						    			        + "buyerId=:t.buyerId,"
		        					    			        + "sellerId=:t.sellerId,"
		        					    			        + "goodsItemId=:t.goodsItemId,"
		        					    			        + "count=:t.count,"
		        					    			        + "status=:t.status,"
		        					    			        + "deleteFlag=:t.deleteFlag,"
		        					    			        + "createUser=:t.createUser,"
		        					    			        + "createAt=:t.createAt,"
		        					    			        + "updateUser=:t.updateUser,"
		        					    			        + "updateAt=:t.updateAt,"
		        						+ " WHERE id=:t.id")
    void update(@SQLParam("t") SCCart sCCart);
    
    @SQL("UPDATE SCCart SET delete_flag=0 WHERE id=:1")
    void deleteById(String id);
}